using MediatR;
using S.O.ErrorCode;
using System.ComponentModel.DataAnnotations;

namespace S.O.Api.Write.Application.Command.Medical
{
    /// <summary>
    /// 创建中药处方命令
    /// 用于医生开具中药处方
    /// </summary>
    public class CreateChineseMedicinePrescriptionCommand : IRequest<APIResult<string>>
    {
        /// <summary>
        /// 患者ID
        /// </summary>
        [Required(ErrorMessage = "患者ID不能为空")]
        public long PatientId { get; set; }

        /// <summary>
        /// 患者姓名
        /// </summary>
        [Required(ErrorMessage = "患者姓名不能为空")]
        [StringLength(50, ErrorMessage = "患者姓名长度不能超过50个字符")]
        public string PatientName { get; set; } = string.Empty;

        /// <summary>
        /// 诊断
        /// </summary>
        [Required(ErrorMessage = "诊断不能为空")]
        [StringLength(500, ErrorMessage = "诊断长度不能超过500个字符")]
        public string Diagnosis { get; set; } = string.Empty;

        /// <summary>
        /// 处方备注
        /// </summary>
        [StringLength(1000, ErrorMessage = "处方备注长度不能超过1000个字符")]
        public string Remark { get; set; } = string.Empty;

        /// <summary>
        /// 医生姓名
        /// </summary>
        [Required(ErrorMessage = "医生姓名不能为空")]
        [StringLength(50, ErrorMessage = "医生姓名长度不能超过50个字符")]
        public string Doctor { get; set; } = string.Empty;

        /// <summary>
        /// 中药列表
        /// </summary>
        [Required(ErrorMessage = "中药列表不能为空")]
        public List<ChineseMedicineItemCommand> Medicines { get; set; } = new List<ChineseMedicineItemCommand>();
    }

    /// <summary>
    /// 中药项命令
    /// 表示处方中的单个中药信息
    /// </summary>
    public class ChineseMedicineItemCommand
    {
        /// <summary>
        /// 药品名称
        /// </summary>
        [Required(ErrorMessage = "药品名称不能为空")]
        [StringLength(100, ErrorMessage = "药品名称长度不能超过100个字符")]
        public string MedicineName { get; set; } = string.Empty;

        /// <summary>
        /// 药品规格
        /// </summary>
        [Required(ErrorMessage = "药品规格不能为空")]
        [StringLength(50, ErrorMessage = "药品规格长度不能超过50个字符")]
        public string Specification { get; set; } = string.Empty;

        /// <summary>
        /// 剂量
        /// </summary>
        [Required(ErrorMessage = "剂量不能为空")]
        [StringLength(50, ErrorMessage = "剂量长度不能超过50个字符")]
        public string Dosage { get; set; } = string.Empty;

        /// <summary>
        /// 频次
        /// </summary>
        [Required(ErrorMessage = "频次不能为空")]
        [StringLength(50, ErrorMessage = "频次长度不能超过50个字符")]
        public string Frequency { get; set; } = string.Empty;

        /// <summary>
        /// 疗程
        /// </summary>
        [Required(ErrorMessage = "疗程不能为空")]
        [StringLength(50, ErrorMessage = "疗程长度不能超过50个字符")]
        public string Duration { get; set; } = string.Empty;

        /// <summary>
        /// 用法
        /// </summary>
        [Required(ErrorMessage = "用法不能为空")]
        [StringLength(50, ErrorMessage = "用法长度不能超过50个字符")]
        public string Usage { get; set; } = string.Empty;

        /// <summary>
        /// 备注
        /// </summary>
        [StringLength(200, ErrorMessage = "备注长度不能超过200个字符")]
        public string Remark { get; set; } = string.Empty;
    }
}